<!DOCTYPE html>
<html lang="en">
<html xmlns:th="http://www.thymleaf.org">
<meta charset="UTF-8">
<script src="../webapp/BootStrap/js/jquery.js"></script>
<script src="../webapp/BootStrap/js/bootstrap.js"></script>
<link rel="stylesheet" href="../webapp/BootStrap/css/bootstrap.css">
<head>
    <meta charset="UTF-8">
    <title>医院管理_医院</title>
    <style>

        #father{
            background-color: #f0f2f5;
            height: 1200px;
            width: 100%;
            float: right;
            border-width: 2px;
            border-color: #cccccc;
            border-style: solid;
        }
        #top{
            background-color: white;
            height: 7%;
            width: 100%;
            float: left;
        }
        #title{
            background-color: white;
            height: 3.5%;
            padding-top:0.5%;
            width: 100%;
            float: left;
            margin-top: 0.5%;
            font-size: 120%;
        }

        #find{
            background-color: white;
            height: 12%;
            width: 96%;
            float: left;
            margin: 2%;
            border-radius: 5px;
            padding: 1%;
        }
        #hospitalname{
            padding-bottom: 3%;
            float: left;
            width: 800px;
            height: 24%;
            margin: 0 0 5px 300px;
        }
        #hospitalname_left,#hospitalname_min,#hospitalname_right{
            float: left;
        }

        #input1{
            width: 400px;
            height: 36px;
            text-align: center;
            font-size: 110%;
        }
        #button1{
            width: 60px;
            height: 36px;
            font-size: 110%;
            background-color: cornflowerblue;
            color: #FFFFFF;
            border: 5px cornflowerblue solid;
            border-top-right-radius: 10px;
            border-bottom-right-radius: 10px;
        }
        #address{
            line-height: 0px;
            height: 35px;
            width: 100%;
            float: left;
            padding-bottom: 15px;
        }
        #inputgrop1_left{
            width: 70px;
            float: left;
            line-height: 10px;
            font-size: 90%;
			margin-left: 3%;
            margin-top: 1%;
        }
        #inputgrop1_right{
            height: 35px;
            width: 35%;
            float: left;
            margin-top: 1%;
        }
        .sele1{
            height: 35px;
            width: 20%;
        }
        .sele2{
            height: 35px;
            width: 50%;
        }
        #gudong{
            height: 35px;
            width: 25%;
            float: left;
            margin-top: 1%;
        }
        #shouyi{
            height: 35px;
            width: 25%;
            float: left;
            margin-top: 1%;
        }
		
		#main{
		    background-color: white;
		    height:67%;
		    width: 96%;
		    float: left;
		    margin: 2%;
			margin-top: 0%;
		    border-radius: 5px;
		    padding: 2%;
		}
		
		.buttongrop1{
			width: 8%;
			height: 6%;
			font-size: 110%;
			background-color: #6495ED;
			color: white;
			border: 1px #6495ED solid;
			border-radius: 3px;
		}
		.buttongrop1:active {
			background-color: white;
			color: black;
			border: 1px lightgray solid;
		    }
		
		#count{
			font-size: 150%;
			width: 96%;
			height:8%;
			background-color: #e4f2ff;
			border: skyblue 2px solid;
			border-radius: 3px;
			margin-top: 2%;
			padding-top: 0.75%;
			padding-left: 4%;
		}
		
		#tableBox{
			font-size: 110%;
			width: 100%;
			height:80%;
			margin-top: 3%;
		}
		table{
			text-align: center;
			width: 100%;
			border-collapse: separate;
			border-spacing: 0px 12px
		}
		th{
            text-align: center;
			padding-top: 1%;
			padding-bottom: 1%;
			background-color: #F0F2F5;
			padding-left: 0px;
			padding-right: 0px;
		}
		tr{
			margin-top: 10px;
			font-size: 120%;
		}
		td{
			border-bottom: lightgray solid 1px;
		}
        .input3{
            width: 65%;
            text-align: center;
            float: right;
        }
        .sele3{
            width: 65%;
            text-align: center;
            float: right;
            text-align: center;
            text-align-last: center;
        }

        .buttongrop2{
            width: 40px;
            height: 40px;
            background-color: white;
            border-radius: 5px;
            border: #6495ED 1px solid;

        }
        .buttongrop{
            color: white;
            width: 75px;
            height: 40px;
            background-color:#6495ED;
            border-radius: 5px;
            border:white 0px solid;

        }


        .shan{
            width: 80%;
            height: 100%;
            border-radius: 5px;

        }

    </style>
    <script>
        function xian(){
            $.ajax({
                url:"/hosp/findXian",
                type:"post",
                datatype:"json",
                success:function(data) {
                    var xian = "";
                    xian+= "<option value=''>-所有-</option>";
                    var mxian="";
                    for(var i in data.xian){
                        var s =data.xian[i];
                        xian+="<option value='"+s.addressid+"'>"+s.addressname+"</option>";
                        mxian+="<option value='"+s.addressid+"'>"+s.addressname+"</option>";
                    }
                    $("#mxian").html(mxian);
                    $("#xian").html(xian);
                }

            })
        }
        sheng()
        function sheng(){
            $.ajax({
                url:"/hosp/findcity",
                type:"post",
                datatype:"json",
                data:{"shi":0,"xian":0},
                success:function(data) {
                    var sheng = "";
                    sheng+= "<option value=''>-所有-</option>";
                    var msheng="";
                    for (var i in data.sheng) {
                        var s = data.sheng[i];
                        sheng += "<option value='" + s.addressid + "'>" + s.addressname + "</option>";
                        msheng += "<option value='" + s.addressid + "'>" + s.addressname + "</option>";
                    }
                    $("#msheng").html(msheng);
                    $("#sheng").html(sheng);

                    var shi = "";
                    shi+= "<option value=''>-所有-</option>";
                    var mshi="";
                    for (var i in data.shi) {
                        var s = data.shi[i];
                        shi += "<option value='" + s.addressid + "'>" + s.addressname + "</option>";
                        mshi += "<option value='" + s.addressid + "'>" + s.addressname + "</option>";
                    }
                    $("#mshi").html(mshi);
                    $("#shi").html(shi);
                }
            })
            xian()
        }
        function  mgaisheng(){
            var sheng= $("#msheng").val();
            $.ajax({
                url:"/hosp/findcity",
                type:"post",
                datatype:"json",
                data:{"shi":sheng},
                success:function(data){
                    var html="";
                    for(var i in data.shi){
                        var s = data.shi[i];

                        html+="<option value='"+s.addressid+"'>"+s.addressname+"</option>";
                    }
                    mgaishi(data.shi[0].addressid);
                    $("#mshi").html(html);
                }
            })
        }

        function gaisheng(){
            var sheng= $("#sheng").val();
            $.ajax({
                url:"/hosp/findcity",
                type:"post",
                datatype:"json",
                data:{"shi":sheng},
                success:function(data){
                    var html="";
                    html+= "<option value=''>-所有-</option>";
                    for(var i in data.shi){
                        var s = data.shi[i];
                        html+="<option value='"+s.addressid+"'>"+s.addressname+"</option>";
                    }
                    gaishi(data.shi[0].addressid);
                    $("#shi").html(html);
                }
            })
        }

        function mgaishi(s){
            var shi= $("#mshi").val();
            if(s!=undefined){
                shi=s;
            }
            $.ajax({
                url:"/hosp/findXian",
                type:"post",
                datatype:"json",
                data:{"xian":shi},
                success:function(data){
                    var html="";
                    for(var i in data.xian){
                        var s = data.xian[i];
                        html+="<option value='"+s.addressid+"'>"+s.addressname+"</option>";
                    }
                    $("#mxian").html(html);
                }
            })
        }

        function gaishi(s){
            var shi= $("#shi").val();
            if(s!=undefined){
               shi=s;
           }
            $.ajax({
                url:"/hosp/findXian",
                type:"post",
                datatype:"json",
                data:{"xian":shi},
                success:function(data){
                  var html= "<option value=''>-所有-</option>";
                    for(var i in data.xian){
                        var s = data.xian[i];
                       html+="<option value='"+s.addressid+"'>"+s.addressname+"</option>";
                    }
                    $("#xian").html(html);
                }
            })
        }


        request()
        function request(){
            $.ajax({
                url:"/hosp/findByHosp",
                type:"post",
                datatype:"json",
                sync:false,
                success:function(data) {
                    show(data)
                }
            })
        }
        function show(data){
            var html="";
            for (var i in data.yiyuan.list){
                var y = data.yiyuan.list[i];
                 html+="<tr>" +
                     "<td>"+y.hospitalinfoname+"</td>"+
                     "<td>"+y.duijieren.username+"</td>"+
                     "<td>"+y.hospitalinfophone+"</td>"+
                     "<td>"+y.hospitalinfocardnumber+"</td>"+
                     "<td>"+y.hospitalinforent+"</td>"+
                     "<td>"+y.hospitalinfosharing+"</td>"+
                     "<td>"+y.hospitalinfocreatetime+"</td>"+
                     "<td><input type='button' class='shan' value='删除'  onclick='sc("+y.hospitalinfoid+")'/></td>"+
                     "</tr>"
            }
            $("tbody").html(html);

            var ren="<option value=''>-所有人员-</option>"
            var gu=""
            for(var i in data.suoyougudong){
                var g = data.suoyougudong[i];
                ren+="<option value='"+g.userid+"'>"+g.username+"</option>";
                gu+="<option value='"+g.userid+"'>"+g.username+"</option>";

            }
            $("#ren").html(ren);
            $("#mgu").html(gu);


            var dui=""
            for(var i in data.duijieren){
                var d = data.duijieren[i];
                dui+="<option value='"+data.duijieren[i].userid+"'>"+data.duijieren[i].username+"</option>";
            }
            $("#mdui").html(dui);

            var yiji="";
            for(var i in data.yiji){
                var y =data.yiji[i]
                yiji+="<option value='"+y.userid+"'>"+y.username+"</option>"
            }
            $("#mfen1").html(yiji);

            var erji="";
            for(var i in data.erji){
                var y =data.erji[i]
                erji+="<option value='"+y.userid+"'>"+y.username+"</option>"
            }
            $("#mfen2").html(erji);

            //分页
            var html3="";
            html3+= "<button type='button' class='buttongrop' onclick='ye("+data.yiyuan.startRow+")'>首页</button>"

            for(var i in data.yiyuan.navigatepageNums){
                html3+="<button type='button' class='buttongrop2' onclick='ye("+data.yiyuan.navigatepageNums[i]+")'>"+data.yiyuan.navigatepageNums[i]+"</button>"
            }
            html3+="<button type='button' class='buttongrop' onclick='ye("+data.yiyuan.endRow+")'>尾页</button>"

            $("#fenye").html(html3);
            $("#countNum").html("查询出的总条数："+data.yiyuan.total);
        }
        function newShow(data){
            var html="";
            for (var i in data.yiyuan.list){
                var y = data.yiyuan.list[i];
                html+="<tr>" +
                    "<td>"+y.hospitalinfoname+"</td>"+
                    "<td>"+y.duijieren.username+"</td>"+
                    "<td>"+y.hospitalinfophone+"</td>"+
                    "<td>"+y.hospitalinfocardnumber+"</td>"+
                    "<td>"+y.hospitalinforent+"</td>"+
                    "<td>"+y.hospitalinfosharing+"</td>"+
                    "<td>"+y.hospitalinfocreatetime+"</td>"+
                    "<td><input type='button' class='shan' value='删除' onclick='sc("+y.hospitalinfoid+")'/></td>"+
                    "</tr>"
            }
            $("tbody").html(html);

            //分页
            var html3="";
            html3+= "<button type='button' class='buttongrop' onclick='ye("+data.yiyuan.navigateFirstPage+")'>首页</button>"

            for(var i in data.yiyuan.navigatepageNums){
                html3+="<button type='button' class='buttongrop2' onclick='ye("+data.yiyuan.navigatepageNums[i]+")'>"+data.yiyuan.navigatepageNums[i]+"</button>"
            }
            html3+="<button type='button' class='buttongrop' onclick='ye("+data.yiyuan.navigateLastPage+")'>尾页</button>"

            $("#fenye").html(html3);
            $("#countNum").html("查询出的总条数："+data.yiyuan.total);
        }

        function pm(num){
            var hospitalinfoprovinceid=$("#sheng").val();
            var hospitalinfocityid=$("#shi").val();
            var hospitalinfocontyid=$("#xian").val();

            var hospitalinfoname= $("#input1").val();
            var usershareholderid=$("#ren").val();
            var hospitalinfosharing= $("#fencheng").val();

            var pageNum=num;
            $.ajax({
                url:"/hosp/findByHosp",
                type:"post",
                datatype:"json",
                data:{"hospitalinfoname":hospitalinfoname,"usershareholderid":usershareholderid,"hospitalinfosharing":hospitalinfosharing,
                    "pageNum":pageNum,"hospitalinfoprovinceid":hospitalinfoprovinceid,"hospitalinfocityid":hospitalinfocityid,"hospitalinfocontyid":hospitalinfocontyid},
                success:function(data){
                    newShow(data);
                }
            })
        }
        function ye(num){
            pm(num);
        }
        function find(){
            var hospitalinfoprovinceid=$("#sheng").val();
            var hospitalinfocityid=$("#shi").val();
            var hospitalinfocontyid=$("#xian").val();

            var hospitalinfoname= $("#input1").val();
            var usershareholderid=$("#ren").val();
            var hospitalinfosharing= $("#fencheng").val();
            $.ajax({
                url:"/hosp/findByHosp",
                type:"post",
                datatype:"json",
                data:{"hospitalinfoname":hospitalinfoname,"usershareholderid":usershareholderid,"hospitalinfosharing":hospitalinfosharing,
                    "hospitalinfoprovinceid":hospitalinfoprovinceid,"hospitalinfocityid":hospitalinfocityid,"hospitalinfocontyid":hospitalinfocontyid},
                success:function(data){
                    newShow(data);
                }
            })

        }

        function sc(num){
            $.ajax({
                url:"/hosp/deleteHosp",
                type:"delete",
                datatype:"json",
                data:{"hospitalinfoid":num},
                    success:function(data){
                        if(data){
                            find();
                        }else{
                            alert("删除失败！");
                        }
                    }
            })
        }


    </script>
</head>

<body>
<div id="father">
    <div id="top">

    </div>

    <div id="title">
        &nbsp;&nbsp;<span style="color: #CCCCCC; ">医院管理/</span>医院
    </div>

    <div id="find">
        <div id="hospitalname">
            <div id="hospitalname_left">
                <svg xmlns="http://www.w3.org/2000/svg" width="35px" height="35px" fill="currentColor" class="bi bi-search" viewBox="0 0 16 16">
                  <path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/>
                </svg>
            </div>

            <div id="hospitalname_min">
                <input id="input1" type="text" placeholder="在此输入查询的医院名称" />
            </div>
            <div id="hospitalname_right">
                <input id="button1" type="button" value="查询" onclick="find()"/>
            </div>
        </div>

        <div id="address">
            <div id="inputgrop1">
                <div id="inputgrop1_left">
                    <p><span>医院的</span></p><p><span>省市县</span></p>
                </div>
            </div>
            <div id="inputgrop1_right">
                <select id="sheng" onchange="gaisheng()" class="sele1">
                    <option>选择省</option>
                </select>
                <select id="shi"  onchange="gaishi()"class="sele1">
                    <option>选择市</option>
                </select>
                <select id="xian" class="sele1">
                    <option>选择县</option>
                </select>
            </div>

            <div id="gudong">
                股东
                <select id="ren" class="sele2">
                    <option>-所有人员-</option>
                </select>
            </div>
            <div id="shouyi">
                收益分成(%)
                <select id="fencheng" class="sele2">
                    <option value="">-所有分成-</option>
                    <option value="5">5</option>
                    <option value="10">10</option>
                    <option value="15">15</option>
                    <option value="20">20</option>
                    <option value="25">25</option>
                    <option value="30">30</option>
                    <option value="35">35</option>
                    <option value="40">40</option>
                    <option value="45">45</option>
                    <option value="50">50</option>
                </select>
            </div>

        </div>
		
    </div>
	
	<div id="main">
        <button type="button" class="buttongrop1" data-toggle="modal" data-target="#myModal">
            新增医院
        </button>
		
		<div id="count">
            <div id="countNum" style="margin-right: 10% ;float: left">总科室数:20000</div>
            <div id="fenye" style="float: left">
                <input type="button"class="buttongrop" value="首页"/>
                <input type="button"class="buttongrop2" value="1"/>
                <input type="button"class="buttongrop2" value="2"/>
                <input type="button"class="buttongrop2" value="3"/>
                <input type="button"class="buttongrop2" value="4"/>
                <input type="button" class="buttongrop" value="尾页"/>
            </div>
		</div>
		
		<div id="tableBox">
			
			<table>
				<thead>
					<tr>

						<th>医院名称</th>
						<th>医院对接人</th>
						<th>医院电话</th>
						<th>银行卡号</th>
						<th>租金(元)</th>
						<th>收益分成(%)</th>
						<th>创建日期</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<tr>

						<td>赫特医院</td>
						<td>赫特</td>
						<td>131313666</td>
						<td>1245612301122222</td>
						<td>20</td>
						<td>30</td>
						<td>2018-10-12 12:20:00</td>
						<td><input  type="button" class="shan" value="删除"/></td>
					</tr>
					<tr>

						<td>赫特医院</td>
						<td>赫特</td>
						<td>131313666</td>
						<td>1245612301122222</td>
						<td>20</td>
						<td>30</td>
						<td>2018-10-12 12:20:00</td>
                        <td><input  type="button" class="shan" value="删除"/></td>
					</tr>
				</tbody>
				
			</table>
			
		</div>
		
	</div>
	
</div>
<div class="modal fade" id="myModal">
    <div class="modal-dialog">
        <div class="modal-content">

            <!-- 模态框头部 -->
            <div class="modal-header" style="background-color: black; color: white;">
                <h4 class="modal-title">新增医院</h4>
                <button type="button" class="close" data-dismiss="modal" style="color: white;">&times;</button>
            </div>

            <!-- 模态框主体 -->
            <div class="modal-body" style="padding-right: 58px;">
                <div style="padding-left: 16px;">
                    选择省市县：
                    <select id="msheng" onchange="mgaisheng()">
                        <option>选择省</option>
                    </select>
                    <select id="mshi" onchange="mgaishi()">
                        <option>选择市</option>
                    </select>
                    <select id="mxian">
                        <option>选择县</option>
                    </select>
                </div>
                <br/>
                <div style="padding-left: 16px;">
                    医院名称：
                    <input type="text" placeholder="请输入医院名称"  class="input3" id="mming"/>
                </div>
                <br/>
                <div  style="padding-left: 16px;">
                    医院对接人：
                    <select class="sele3" id="mdui">
                        <option>-选择医院对接人-</option>
                    </select>
                </div>
                <br/>
                <div  style="padding-left: 16px;">
                    医院电话：
                    <input type="text" placeholder="请输入对接人电话"  class="input3" id="mdian"/>

                </div>
                <br/>
                <div  style="padding-left: 16px;">
                    设置租金金额：
                    <input type="text" placeholder="请设置医院租金(单位:元)" class="input3" id="mzu"/>
                </div>
                <br/>
                <div  style="padding-left: 16px;">
                    银行卡号：
                    <input type="text" placeholder="请输入医院银行卡号"  class="input3" id="mka"/>
                </div>
                <br/>
                <div  style="padding-left: 16px;">
                    收益分成：
                    <select id="mfencheng" class="sele3">
                        <option value="5">5</option>
                        <option value="10">10</option>
                        <option value="15">15</option>
                        <option value="20">20</option>
                        <option value="25">25</option>
                        <option value="30">30</option>
                        <option value="35">35</option>
                        <option value="40">40</option>
                        <option value="45">45</option>
                        <option value="50">50</option>
                    </select>
                </div>
                <br/>
                <div  style="padding-left: 16px;">
                    股东：
                    <select class="sele3" id="mgu">
                        <option>-请选择股东-</option>
                    </select>
                </div>
                <br/>
                <div  style="padding-left: 16px;">
                    一级分销商：
                    <select class="sele3" id="mfen1">
                        <option>-请选择分销商-</option>
                    </select>
                </div>
                <br/>
                <div  style="padding-left: 16px;">
                    二级分销商：
                    <select class="sele3" id="mfen2">
                        <option>-请选择分销商-</option>
                    </select>
                </div>

            </div>

            <!-- 模态框底部 -->
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="tijiao()">提交</button>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
            </div>

        </div>
    </div>
</div>
</body>
</html>
<script>
    function tijiao(){
        var hospitalinfoprovinceid=$("#msheng").val();
        var hospitalinfocityid=$("#mshi").val();
        var hospitalinfocontyid=$("#mxian").val();

        var hospitalinfoname= $("#mming").val();
        var userid= $("#mdui").val();
        var hospitalinfophone= $("#mdian").val();
        var hospitalinforent= $("#mzu").val();
        var hospitalinfocardnumber = $("#mka").val();
        var hospitalinfosharing = $("#mfencheng").val();
        var usershareholderid=$("#mgu").val();
        var userdistributorsid1=$("#mfen1").val();
        var userdistributorsid2=$("#mfen2").val();

        $.ajax({
            url:"/hosp/insertHosp",
            type:"post",
            datatype:"json",
            data:{"hospitalinfoprovinceid":hospitalinfoprovinceid,"hospitalinfocityid":hospitalinfocityid,"hospitalinfocontyid":hospitalinfocontyid,
            "hospitalinfoname":hospitalinfoname,"hospitalinfophone":hospitalinfophone,"hospitalinforent":hospitalinforent,"hospitalinfocardnumber":hospitalinfocardnumber,
            "hospitalinfosharing":hospitalinfosharing,"usershareholderid":usershareholderid,"userdistributorsid1":userdistributorsid1,"userdistributorsid2":userdistributorsid2,
            "userid":userid
            },
            success:function(data){
                if(data){
                    find();
                    alert("添加成功！");

                }else{
                    alert("添加失败！");
                }
            }
        })

    }

</script>
